/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clientGUI;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;

/**
 *
 * @author Wiko Putrawan
 */
public class FourboxPreferences extends javax.swing.JFrame {

    public FourboxGUI fourbox;
    public File workingDir;

    /**
     * Creates new form FourboxPreferences
     */
    public FourboxPreferences(FourboxGUI fourbox) {
        initComponents();
        this.setDefaultCloseOperation(HIDE_ON_CLOSE);
        this.fourbox = fourbox;
        this.workingDir = fourbox.client.workingDir;
        this.locationTextField.setText(workingDir.toString());
        this.locationTextField.setEnabled(false);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        downloadRate = new javax.swing.ButtonGroup();
        uploadRate = new javax.swing.ButtonGroup();
        proxySetting = new javax.swing.ButtonGroup();
        prefTabbedPane = new javax.swing.JTabbedPane();
        general = new javax.swing.JPanel();
        showNotif = new javax.swing.JCheckBox();
        startOnStartup = new javax.swing.JCheckBox();
        enableLAN = new javax.swing.JCheckBox();
        account = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        unlink = new javax.swing.JButton();
        bandwidth = new javax.swing.JPanel();
        downloadRateLabel = new javax.swing.JLabel();
        dontLimitDR = new javax.swing.JRadioButton();
        limitToDR = new javax.swing.JRadioButton();
        limitToTextFieldDR = new javax.swing.JTextField();
        limitToLabelDR = new javax.swing.JLabel();
        uploadRateLabel = new javax.swing.JLabel();
        dontLimitUR = new javax.swing.JRadioButton();
        limitAutoUR = new javax.swing.JRadioButton();
        limitToUR = new javax.swing.JRadioButton();
        limitToTextFieldUR = new javax.swing.JTextField();
        limitToLabelUR = new javax.swing.JLabel();
        proxies = new javax.swing.JPanel();
        proxySettingLabel = new javax.swing.JLabel();
        noProxy = new javax.swing.JRadioButton();
        autodetect = new javax.swing.JRadioButton();
        manual = new javax.swing.JRadioButton();
        proxyTypeLabel = new javax.swing.JLabel();
        proxyType = new javax.swing.JComboBox();
        serverLabel = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        portLabel = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        isHavePassword = new javax.swing.JCheckBox();
        usernameLabel = new javax.swing.JLabel();
        usernameTextField = new javax.swing.JTextField();
        passwordLabel = new javax.swing.JLabel();
        passwordTextField = new javax.swing.JTextField();
        advanced = new javax.swing.JPanel();
        locationLabel = new javax.swing.JLabel();
        locationTextField = new javax.swing.JTextField();
        locationButton = new javax.swing.JButton();
        syncLabel1 = new javax.swing.JLabel();
        syncLabel2 = new javax.swing.JLabel();
        syncButton = new javax.swing.JButton();
        languageLabel = new javax.swing.JLabel();
        languageComboBox = new javax.swing.JComboBox();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();

        downloadRate.add(dontLimitDR);
        downloadRate.add(limitToDR);

        uploadRate.add(dontLimitUR);
        uploadRate.add(limitAutoUR);
        uploadRate.add(limitToUR);

        proxySetting.add(noProxy);
        proxySetting.add(autodetect);
        proxySetting.add(manual);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Fourbox Preferences");

        general.setName(""); // NOI18N

        showNotif.setText("Show desktop notofication");

        startOnStartup.setText("Start Fourbox on system startup");

        enableLAN.setText("Enable LAN sync");

        javax.swing.GroupLayout generalLayout = new javax.swing.GroupLayout(general);
        general.setLayout(generalLayout);
        generalLayout.setHorizontalGroup(
            generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(showNotif)
                    .addComponent(startOnStartup)
                    .addComponent(enableLAN))
                .addContainerGap(225, Short.MAX_VALUE))
        );
        generalLayout.setVerticalGroup(
            generalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(generalLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(showNotif)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(startOnStartup)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(enableLAN)
                .addContainerGap(193, Short.MAX_VALUE))
        );

        prefTabbedPane.addTab("General", general);

        jLabel1.setText("This computer is linked to:");

        jLabel2.setText("...");

        unlink.setText("Unlink This Computer...");

        javax.swing.GroupLayout accountLayout = new javax.swing.GroupLayout(account);
        account.setLayout(accountLayout);
        accountLayout.setHorizontalGroup(
            accountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accountLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(accountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(accountLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel2)
                        .addGap(0, 252, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, accountLayout.createSequentialGroup()
                        .addGap(0, 249, Short.MAX_VALUE)
                        .addComponent(unlink)))
                .addContainerGap())
        );
        accountLayout.setVerticalGroup(
            accountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(accountLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(accountLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(unlink)
                .addContainerGap(215, Short.MAX_VALUE))
        );

        prefTabbedPane.addTab("Account", account);

        downloadRateLabel.setText("Download rate");

        dontLimitDR.setText("Don't limit");
        dontLimitDR.setToolTipText("");

        limitToDR.setText("Limit to:");

        limitToLabelDR.setText("kB/s");

        uploadRateLabel.setText("Upload rate");

        dontLimitUR.setText("Don't limit");

        limitAutoUR.setText("Limit automatically");

        limitToUR.setText("Limit to:");

        limitToLabelUR.setText("kB/s");

        javax.swing.GroupLayout bandwidthLayout = new javax.swing.GroupLayout(bandwidth);
        bandwidth.setLayout(bandwidthLayout);
        bandwidthLayout.setHorizontalGroup(
            bandwidthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bandwidthLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(bandwidthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(bandwidthLayout.createSequentialGroup()
                        .addComponent(limitToUR)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limitToTextFieldUR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limitToLabelUR))
                    .addComponent(limitAutoUR)
                    .addGroup(bandwidthLayout.createSequentialGroup()
                        .addComponent(limitToDR)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limitToTextFieldDR, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addComponent(limitToLabelDR))
                    .addComponent(dontLimitDR)
                    .addComponent(downloadRateLabel)
                    .addComponent(uploadRateLabel)
                    .addComponent(dontLimitUR))
                .addContainerGap(248, Short.MAX_VALUE))
        );

        bandwidthLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {limitToTextFieldDR, limitToTextFieldUR});

        bandwidthLayout.setVerticalGroup(
            bandwidthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(bandwidthLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(downloadRateLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dontLimitDR)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(bandwidthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(limitToLabelDR)
                    .addComponent(limitToDR)
                    .addComponent(limitToTextFieldDR))
                .addGap(18, 18, 18)
                .addComponent(uploadRateLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dontLimitUR)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(limitAutoUR)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(bandwidthLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(limitToUR)
                    .addComponent(limitToTextFieldUR, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(limitToLabelUR))
                .addGap(59, 59, 59))
        );

        prefTabbedPane.addTab("Bandwidth", bandwidth);

        proxySettingLabel.setText("Proxy setting:");

        noProxy.setText("No proxy");

        autodetect.setText("Auto-detect");

        manual.setText("Manual");

        proxyTypeLabel.setText("Proxy type:");

        proxyType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "HTTP", "SOCKS4", "SOCKS5" }));

        serverLabel.setText("Server:");

        portLabel.setText(":");

        isHavePassword.setText("Proxy server requires a password");

        usernameLabel.setText("Username:");

        passwordLabel.setText("Password:");

        javax.swing.GroupLayout proxiesLayout = new javax.swing.GroupLayout(proxies);
        proxies.setLayout(proxiesLayout);
        proxiesLayout.setHorizontalGroup(
            proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(proxiesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(passwordLabel)
                    .addComponent(usernameLabel)
                    .addComponent(serverLabel)
                    .addComponent(proxyTypeLabel)
                    .addComponent(proxySettingLabel))
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(proxiesLayout.createSequentialGroup()
                        .addGap(14, 14, 14)
                        .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(manual)
                            .addComponent(autodetect)
                            .addComponent(noProxy)))
                    .addGroup(proxiesLayout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(proxyType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(proxiesLayout.createSequentialGroup()
                                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(portLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(isHavePassword)
                            .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(passwordTextField, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 126, Short.MAX_VALUE)
                                .addComponent(usernameTextField, javax.swing.GroupLayout.Alignment.LEADING)))))
                .addContainerGap(68, Short.MAX_VALUE))
        );
        proxiesLayout.setVerticalGroup(
            proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(proxiesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(proxySettingLabel)
                    .addComponent(noProxy))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(autodetect)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(manual)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(proxyTypeLabel)
                    .addComponent(proxyType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(serverLabel)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(portLabel)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(isHavePassword)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(usernameLabel)
                    .addComponent(usernameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(proxiesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passwordLabel)
                    .addComponent(passwordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(57, Short.MAX_VALUE))
        );

        prefTabbedPane.addTab("Proxies", proxies);

        locationLabel.setText("Fourbox location");

        locationTextField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                locationTextFieldActionPerformed(evt);
            }
        });

        locationButton.setText("Move...");
        locationButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                locationButtonActionPerformed(evt);
            }
        });

        syncLabel1.setText("Selective sync");

        syncLabel2.setText("Select which folder sync to this computer:");

        syncButton.setText("Selective Sync...");

        languageLabel.setText("Language");

        languageComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Language 1", "Language 2", "Language 3", "Language 4" }));

        javax.swing.GroupLayout advancedLayout = new javax.swing.GroupLayout(advanced);
        advanced.setLayout(advancedLayout);
        advancedLayout.setHorizontalGroup(
            advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(locationLabel)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, advancedLayout.createSequentialGroup()
                        .addGroup(advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(syncLabel2)
                            .addComponent(syncLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(syncButton))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, advancedLayout.createSequentialGroup()
                        .addComponent(locationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(locationButton))
                    .addComponent(languageLabel)
                    .addComponent(languageComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(82, Short.MAX_VALUE))
        );
        advancedLayout.setVerticalGroup(
            advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(advancedLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(locationLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(locationTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(locationButton))
                .addGap(18, 18, 18)
                .addComponent(syncLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(advancedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(syncLabel2)
                    .addComponent(syncButton))
                .addGap(18, 18, 18)
                .addComponent(languageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(languageComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(96, Short.MAX_VALUE))
        );

        prefTabbedPane.addTab("Advanced", advanced);

        ok.setText("OK");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });

        cancel.setText("Cancel");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(prefTabbedPane)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 301, Short.MAX_VALUE)
                        .addComponent(ok)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancel)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(prefTabbedPane)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cancel)
                    .addComponent(ok))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        this.setVisible(false);
        try {
            if (!this.fourbox.client.connectionOn) {
                this.fourbox.client.changeWorkDir(this.workingDir);
                this.workingDir = this.fourbox.client.workingDir;
            }
        } catch (IOException ex) {
            Logger.getLogger(FourboxPreferences.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_okActionPerformed

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed
        this.setVisible(false);
        this.workingDir = this.fourbox.client.workingDir;
    }//GEN-LAST:event_cancelActionPerformed

    private void locationButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationButtonActionPerformed
        // TODO add your handling code here:
        JFileChooser fileChooser = new JFileChooser(fourbox.client.workingDir);
        fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int returnVal = fileChooser.showOpenDialog(FourboxPreferences.this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            workingDir = fileChooser.getSelectedFile();
            //This is where a real application would open the file.            
            locationTextField.setText(workingDir.toString());
            locationTextField.setEnabled(false);
        } else {
        }

    }//GEN-LAST:event_locationButtonActionPerformed

    private void locationTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationTextFieldActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_locationTextFieldActionPerformed

    @Override
    public void show() {
        super.show();
        this.locationButton.setEnabled(!this.fourbox.client.connectionOn);
        this.workingDir = this.fourbox.client.workingDir;
        this.locationTextField.setText(this.workingDir.toString());

    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /*
//         * Set the Nimbus look and feel
//         */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /*
//         * If Nimbus (introduced in Java SE 6) is not available, stay with the
//         * default look and feel. For details see
//         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(FourboxPreferences.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(FourboxPreferences.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(FourboxPreferences.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(FourboxPreferences.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /*
//         * Create and display the form
//         */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            @Override
//            public void run() {
//                new FourboxPreferences().setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel account;
    private javax.swing.JPanel advanced;
    private javax.swing.JRadioButton autodetect;
    private javax.swing.JPanel bandwidth;
    private javax.swing.JButton cancel;
    private javax.swing.JRadioButton dontLimitDR;
    private javax.swing.JRadioButton dontLimitUR;
    private javax.swing.ButtonGroup downloadRate;
    private javax.swing.JLabel downloadRateLabel;
    private javax.swing.JCheckBox enableLAN;
    private javax.swing.JPanel general;
    private javax.swing.JCheckBox isHavePassword;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JComboBox languageComboBox;
    private javax.swing.JLabel languageLabel;
    private javax.swing.JRadioButton limitAutoUR;
    private javax.swing.JRadioButton limitToDR;
    private javax.swing.JLabel limitToLabelDR;
    private javax.swing.JLabel limitToLabelUR;
    private javax.swing.JTextField limitToTextFieldDR;
    private javax.swing.JTextField limitToTextFieldUR;
    private javax.swing.JRadioButton limitToUR;
    private javax.swing.JButton locationButton;
    private javax.swing.JLabel locationLabel;
    private javax.swing.JTextField locationTextField;
    private javax.swing.JRadioButton manual;
    private javax.swing.JRadioButton noProxy;
    private javax.swing.JButton ok;
    private javax.swing.JLabel passwordLabel;
    private javax.swing.JTextField passwordTextField;
    private javax.swing.JLabel portLabel;
    private javax.swing.JTabbedPane prefTabbedPane;
    private javax.swing.JPanel proxies;
    private javax.swing.ButtonGroup proxySetting;
    private javax.swing.JLabel proxySettingLabel;
    private javax.swing.JComboBox proxyType;
    private javax.swing.JLabel proxyTypeLabel;
    private javax.swing.JLabel serverLabel;
    private javax.swing.JCheckBox showNotif;
    private javax.swing.JCheckBox startOnStartup;
    private javax.swing.JButton syncButton;
    private javax.swing.JLabel syncLabel1;
    private javax.swing.JLabel syncLabel2;
    private javax.swing.JButton unlink;
    private javax.swing.ButtonGroup uploadRate;
    private javax.swing.JLabel uploadRateLabel;
    private javax.swing.JLabel usernameLabel;
    private javax.swing.JTextField usernameTextField;
    // End of variables declaration//GEN-END:variables
}
